package com.gs.wzmanager.controller.rest;

import com.gs.wzmanager.service.RoleService;
import com.gs.wzmanager.utils.HttpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/rest/role")
public class RoleRestController {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private RoleService roleService;

    @RequestMapping(value = "/res/update",method = RequestMethod.POST)
    public ResponseEntity updateRes(Integer aOrd, Integer roleId, Integer resId) {
        logger.info("message->{}",resId+""+roleId+""+aOrd);
        if (aOrd == 0){
            roleService.deleteRoleResource(roleId,resId);
        }else {
            roleService.addRoleResource(roleId,resId);
        }
        return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
    }
}
